package studentmanage.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import studentmanage.DTO.GradeDTO;
import studentmanage.VO.GradesVO;
import studentmanage.entity.Grades;
import studentmanage.entity.Students;
import studentmanage.service.GradeService;
import studentmanage.tools.result.Result;

import java.util.List;

@Api(tags = "成绩相关接口")
@RestController
@Slf4j
@RequestMapping("/grades")
public class gradesController {
    @Autowired
    private GradeService gradeService;
    @PostMapping("/selectGrade")
    @ApiOperation("查看学生的成绩")
    public Result<List<GradesVO>> selectGrade(@RequestBody GradeDTO gradeDTO){
        List<GradesVO> list =gradeService.selectGrade(gradeDTO);
        return Result.success(list);
    }

    @PostMapping("/add")
    @ApiOperation("添加成绩")
    public Result<String> addGrade(@RequestBody Grades grades){
        gradeService.addGrade(grades);
        return Result.success("添加成功");
    }

    @DeleteMapping("/delete/{gradeId}")
    @ApiOperation("删除成绩")
    public Result<String> deleteGrade(@PathVariable long gradeId){
        gradeService.deleteGrade(gradeId);
        return Result.success("删除成功");
    }
    @PostMapping("/update")
    @ApiOperation("修改成绩")
    public Result<String> updateGrade(@RequestBody Grades grades){
        gradeService.updateGrade(grades);
        return Result.success("修改成功");
    }

}
